<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .one{
            color: red;
        }
    </style>    
</head>
<body>
    <div id="test">
        hellow world
    </div>
    <script>
        var test=document.getElementById("test");
        // className 
        //test.className="one"//给id为test的元素增加一个类“one"
        test.onclick=function(){
            // obj.classList.contains() 判断某个元素是否有某个CLASS
            // this.className="one";
            if(this.classList.contains("one")){
                this.className=""
            }else{
                this.className="one"
            }
        }
    
    
    </script>
</body>
</html>